/**
 * Created by loso on 2017/3/9.
 */
public class _415_AddStrings {
    public static void main(String[] args) {
        System.out.println(addStrings("123","123"));
    }

    public static String addStrings(String num1, String num2) {
        StringBuffer stringBuffer = new StringBuffer();
        int len = num1.length()>num2.length()?num1.length():num2.length();
        int cout = 0;
        int num = 0;
        for (int i = 0; i < len; i++) {
            num = cout;
            if (i<num1.length()){
                num += num1.charAt(num1.length() - 1 - i) - '0';
            }
            if(i<num2.length()){
                num += num2.charAt(num2.length() - 1 - i) - '0';
            }

            cout = num>9?1:0;
            num = num%10;
            stringBuffer.append((char)(num+'0'));
        }
        if (cout != 0){
            stringBuffer.append((char)(cout+'0'));
        }
        return stringBuffer.reverse().toString();
    }
}
